package leetcode.code2063;

import leetcode.IDebug;

public class Solution implements IDebug {

	public long countVowels(String word) {
		char[] cs = word.toCharArray();
		int len = cs.length;
		long dp = this.isVowel(cs[0]) ? 1 : 0;
		long ans = dp;
		for (int i = 1; i < len; i++) {
			char cur = cs[i];
			dp += this.isVowel(cur) ? i + 1 : 0;
			ans += dp;
		}
		return ans;
	}



	private boolean isVowel(char c) {
		return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
	}
	
	public long countVowels1(String word) {
		char[] cs = word.toCharArray();
		int len = cs.length;
		long[] dp = new long[len];
		dp[0] = this.isVowel(cs[0]) ? 1 : 0;
		long ans = (long) dp[0];
		for (int i = 1; i < len; i++) {
			char cur = cs[i];
			dp[i] = dp[i - 1];
			dp[i] += this.isVowel(cur) ? i + 1 : 0;
			ans += dp[i];
		}
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
